const { handleStar } = require("../../utils/Star")
Page({
  data: {
    
  },
  onLoad: function (options) {
    var {id} = options
    var url = `http://47.108.197.28:4000/api/movieDetail?id=${id}`
    wx.request({
      url,
      header: {'content-type':'application/json'},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (res)=>{
        var detail = []
        console.log(res)
        var res = res.data.res
        res.forEach(item => {
          var { title, pic, rating, labels } = item;
          var star = rating
          detail.push({
            title,
            pic,
            rating,
            labels,
            star: handleStar(star)
          })
        })
        console.log(detail)
        this.setData({
          detail
        })
      },
    });
  }
})